<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-select v-model="dataForm.key" clearable placeholder="审批状态">
          <el-option :key="0" label="审批中" :value="0"></el-option>
          <el-option :key="1" label="审批通过" :value="1"></el-option>
          <el-option :key="2" label="驳回审批" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%"
    >
      <el-table-column
        prop="restName"
        header-align="center"
        align="center"
        label="请假人"
      >
      </el-table-column>
      <el-table-column
        prop="auditPeopleName"
        header-align="center"
        align="center"
        label="审批人"
      >
      </el-table-column>
      <el-table-column
        prop="auditStatus"
        header-align="center"
        width="80"
        align="center"
        label="审批状态"
      >
        <template slot-scope="scope">
          <el-tag
            :key="scope.row.auditStatus"
            :type="
              scope.row.auditStatus == 0
                ? 'danger'
                : scope.row.auditStatus == 1
                ? 'success'
                : 'info'
            "
            effect="plain"
            size="small"
            >{{
              scope.row.auditStatus == 0
                ? "审核中"
                : scope.row.auditStatus == 1
                ? "审批通过"
                : "驳回"
            }}</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column
        prop="reason"
        header-align="center"
        align="center"
        width="200px"
        label="请假原因">
      </el-table-column>
      <el-table-column
        prop="startTime"
        header-align="center"
        align="center"
        width="200px"
        label="请假开始时间">
      </el-table-column>
      <el-table-column
        prop="endTime"
        header-align="center"
        align="center"
        width="200px"
        label="请假结束时间">
      </el-table-column>
      <el-table-column
        prop="auditTime"
        header-align="center"
        align="center"
        width="200px"
        label="审批时间">
      </el-table-column>
      </el-table-column>
      <el-table-column
        prop="auditLevel"
        header-align="center"
        width="100"
        align="center"
        label="审核阶段"
      >
        <template slot-scope="scope">
          <el-tag type="" size="small">{{
            scope.row.auditLevel == 1 ? "班主任审核" : "书记审核"
          }}</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dataForm: {
        key: "",
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false,
    };
  },
  activated() {
    this.getDataList();
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("/secretary/audit/allList"),
        method: "get",
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize,
          auditStatus: this.dataForm.key,
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list;
          this.totalPage = data.page.totalCount;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
        this.dataListLoading = false;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val;
    },
  },
};
</script>
